#!/bin/bash

cd /
image=$1
if [ "$image" = "" ]; then
    echo "Please specify directory containing installable packages"
    echo "usage: installImages  <directory>"
    exit 1
fi

# check if directory exists
if [ ! -d $image ]; then
    echo "The directory $image doesn't exist"
    echo "Please specify directory containing the installable packages."
    exit 2
fi

LANG=en_US
export LANG
echo "--- Installing U801084 -----"
cp $image/boot.local /etc/rc.d/
chown root.root /etc/rc.d/boot.local
chmod 755 /etc/rc.d/boot.local
cp $image/restore /opt/hsc/bin/
chown bin.bin /opt/hsc/bin/restore
chmod 555 /opt/hsc/bin/restore
/sbin/chkconfig --del hmcpostcfg -f 2>&1 >/dev/null
cp $image/hmcpostcfg /etc/rc.d/
chown root.root /etc/rc.d/hmcpostcfg
chmod 555 /etc/rc.d/hmcpostcfg
/sbin/chkconfig --add hmcpostcfg
/sbin/chkconfig --del hmcRestore -f 2>&1 >/dev/null
mount /mnt/upgrade
if [ $? -eq 0 ]
then
   > /mnt/upgrade/iqybcrit.dat
   umount /mnt/upgrade
fi

grep -q "U801084: Restore Console Data Fix (11-22-2004)" /opt/hsc/data/version
if [ $? -ne 0 ]
then
    echo "U801084: Restore Console Data Fix (11-22-2004)" >> /opt/hsc/data/version
fi
exit 0
